package objects.alignments;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

import objects.Subset;
import objects.ValidPosition;

import Control.Zoomable;

public class IntronAlignment extends SingleAlignment {

	public IntronAlignment(int start, Subset sub, String cigarString) {
		super(start, 1, sub, cigarString);
	}

	@Override
	public void draw(Graphics graphic, int x, int y) {
		// Since it's an intron alignment, the valid positions should be 1.
		if (this.getValidPositions().size() != 1)
			System.out.println("IntronAlignment size is off..");

		ValidPosition vp = this.getValidPositions().get(0);
		Color color = this.getParent().getTreatmentParent().getColor();

		Graphics2D g2d = (Graphics2D) graphic;
		g2d.setColor(color);
		vp.x = x + Zoomable.getInstance().calcDist(vp.start);
		vp.y = y;
		vp.width = Zoomable.getInstance().calcDist(vp.getDistance());
		vp.height = 4;
		g2d.fill(vp);
		g2d.setColor(new Color(100, 100, 100));
		g2d.draw(vp);
	}

	@Override
	public String toString() {
		return "Intron Alignment";
	}
	
	@Override
	public boolean equals(Alignment other) {
		return this.getStart() == other.getStart();
	}
	
	@Override
	public int compareTo(Alignment other) {		
		return this.getStart() - other.getStart();
	}

	public static IntronCollapsedAlignment collapse (IntronAlignment one, IntronAlignment two) 
	{
		return new IntronCollapsedAlignment(one, two);
	}
}
